lunomods.readdir = function(dirname, filtro, grep) --Deve ser obrigatorio um grep. (Ja tentei criar uma funcaosem grep, mas nao funfa por causa do comando 'ls')
	if filtro~=nil and filtro~="" then
		filtro = "--file-type "..filtro
	else
		filtro = ""
	end
	
	if grep~=nil and grep~="" then
		grep = " | grep \""..grep.."\" "
	else
		grep = ""
	end
	
	local callit = os.tmpname()
	--os.execute("ls -a1 "..dirname .. " >"..callit)
	local comando = "ls "..filtro.." \""..dirname .. "\" "..grep.." >"..callit
	--print("################################## [lunomods.readdir] comando = "..comando)
	os.execute(comando)
	local f = io.open(callit,"r")
	--local rv = f:read("*all")
	local lines = {}
	while true do
		local line = f:read("*line")
		if line == nil then break end
		--print("################################## [lunomods.readdir] line = "..line)
		table.insert(lines, line)
	end
	table.sort(lines)
	f:close()
	os.remove(callit)
	return lines
	--[[
	FONTE: 
		* http://www.wellho.net/resources/ex.php4?item=u112/dlisting
		* http://www.lua.org/pil/21.1.html
	]]--
end
